package xyz.molzhao.performance;

import xyz.molzhao.util.CommonUtil;

import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;

public class TerribleCode {
    public static void main(String[] args) {
        CommonUtil.createBehavior("小明和小伙伴们 进餐厅点菜");
        long startTime = System.currentTimeMillis();

        ArrayList<Dish> dishes = new ArrayList<>();
        for (int i = 0; i < 7; i++) {
            dishes.add(new Dish("菜" + i, 1));
        }

        dishes.forEach(dish -> CompletableFuture.runAsync(dish::make).join());
        CommonUtil.createBehavior("菜都做好了，上桌" + (System.currentTimeMillis() - startTime));
    }
}
